﻿using com.guojin.core.io.message;
using com.guojin.mj.net.message.login;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class WarRecordPage : EventManager
{
    public Button closeBtn;
    public GameObject content;

    private static WarRecordPage instance;
    public static WarRecordPage GetInstance()
    {
        return instance;
    }
    void Awake()
    {
        instance = this;
    }

    public override void InformationSetting()
    {
        AddListenerToButton(closeBtn, CloseBtnClick);
    }

    public void OnReceive720(string msg, Message data)
    {
        WarRecordListRet rhlist = (WarRecordListRet)data;

        if (rhlist == null)
        {
            TooL.ShowNoticePage("当前玩家没有战绩！");
        }
        else if (rhlist.HistoryList.Count > 0)
        {
            for (int i = 0; i < rhlist.HistoryList.Count; i++)
            {
                GameObject obj = TooL.LoadPrefab(content, "WarRecordItem");
               obj.GetComponent<WarRecordItemPage>().SetMsg(rhlist.HistoryList[i]);
            }
        }
    }

    public void CloseBtnClick()
    {
        DestroyImmediate(gameObject);
    }
}
